package set.test;

import set.Car;

import java.util.LinkedHashSet;

public class LinkedHashSetDemo {
    public static void main(String[] args) {
        //1.创建车对象
        Car c1 = new Car("bmw", 1000);
        Car c2 = new Car("kk", 1000);
        Car c3 = new Car("ww", 1000);
        Car c4 = new Car("bmw", 1000);
        //2.创建集合
        LinkedHashSet<Car> lhs = new LinkedHashSet<>();
        //3.将集合添加到集合中
        System.out.println(lhs.add(c1));
        System.out.println(lhs.add(c2));
        System.out.println(lhs.add(c3));
        System.out.println(lhs.add(c4));
        //4.打印集合 取的顺序和存的顺序一样
        System.out.println(lhs);
    }

}
